package cn.iocoder.yudao.module.mqtt.dal.mysql.devicegroup;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mqtt.dal.dataobject.devicegroup.DeviceGroupDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mqtt.controller.admin.devicegroup.vo.*;

/**
 * 设备分组 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface DeviceGroupMapper extends BaseMapperX<DeviceGroupDO> {

    default List<DeviceGroupDO> selectList(DeviceGroupListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DeviceGroupDO>()
                .eqIfPresent(DeviceGroupDO::getParentId, reqVO.getParentId())
                .likeIfPresent(DeviceGroupDO::getName, reqVO.getName())
                .eqIfPresent(DeviceGroupDO::getStatus, reqVO.getStatus())
                .eqIfPresent(DeviceGroupDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(DeviceGroupDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeviceGroupDO::getId));
    }



	default DeviceGroupDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(DeviceGroupDO::getParentId, parentId, DeviceGroupDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(DeviceGroupDO::getParentId, parentId);
    }

}